// 系统
export default {
  namespaced: true,
  state: {
    // 底部公司信息
    footer: '© 2019-2020 豆芽 个人博客网站 豫ICP备19006846号',
    // 占位头像
    avatar: 'https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png',
    // 占位图片
    image: 'https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png',
    // 主题
    theme: '#409EFF',
    // 控件大小
    controlSize: 'mini'
  },
  mutations: {
    SET_FOOTER: (state, footer) => {
      state.footer = footer
    },
    SET_AVATAR: (state, avatar) => {
      state.avatar = avatar
    },
    SET_IMAGE: (state, image) => {
      state.image = image
    },
    SET_THEME (state, theme) {
      state.theme = theme
    },
    SET_CONTROLSIZE (state, controlSize) {
      state.controlSize = controlSize
    }
  },
  actions: {
    getSystemInfo({ commit, state }) {
      return new Promise((resolve, reject) => {
        let _theme = localStorage.getItem('COLOR_THEME')
        if (!_theme) {
          // 此处需要从后台接口读取
          // 接口请求失败，使用默认的
          _theme = state.theme
        }
        commit('SET_THEME', _theme)
        resolve({ theme: _theme })
      })
    }
  }
}
